<template>
  	<el-dialog class="modify-class" width="1200px" title="预验收" visible append-to-body :close-on-click-modal="false" :before-close="beforeClose">
	  	<c-table class="mt20 mb20"  :table-column="tableColumn" :table-data="detailData" :operation="false" @assembling="assemblingHandle(0)" @productionUnits="assemblingHandle(1)" @designUnits="designUnitsHandle(1)" @hisSetOfUnits="designUnitsHandle(0)" @serial="documentHandle"></c-table>
		<AssemblingDialog v-if="showDetailDialog" :detailData="assemblingData" :title="title" @close="closeHandle"></AssemblingDialog>
		<designUnitsDialog v-if="showDesignDialog" :detailData="designUnitsData" :title="title" @close="closeHandle"></designUnitsDialog>
		<documentDialog v-if="showDocumentDialog" :detailData="documentData" @close="closeHandle"></documentDialog>
  	</el-dialog>
</template>

<script>
import AssemblingDialog from './AssemblingDialog.vue'
import designUnitsDialog from './designUnitsDialog.vue'
import documentDialog from './documentDialog.vue'
import acceptanceApi from '@/apis/overview/acceptance.js'
export default {
	components: {AssemblingDialog,designUnitsDialog,documentDialog},
  	props: {
    	detailData: {
      		type: Array,
      		default() {
        		return []
      		}
    	}
  	},
  	data() {
	    return {
			showDetailDialog:false,
			showDesignDialog:false,
			showDocumentDialog:false,
			title:'',
	      	tableColumn: {
		        deviceNo: {
		          	label: '设备编号',
		          	columnProp: {
		            	align: 'center'
		          	}
		        },
		        assembling: {
		            type: 'link',
		          	label: '装配环节',
          			text: '详情',
		          	columnProp: {
		            	align: 'center'
		          	},
		        },
		        productionUnits: {
		          	type: 'link',
		          	label: '整机测试',
          			text: '详情',
		          	columnProp: {
		            	align: 'center'
		          	},
		        },
		        designUnits: {
		          	type: 'link',
		          	label: '验收试验',
          			text: '详情',
		          	columnProp: {
		            	align: 'center'
		          	},
		        },
		        hisSetOfUnits: {
		          	type: 'link',
		          	label: '例行试验',
          			text: '详情',
		          	columnProp: {
		            	align: 'center'
		          	},
		        },
		        serial: {
		          	type: 'link',
		          	label: '文档验收',
          			text: '详情',
		          	columnProp: {
		            	align: 'center'
		          	},
		        },
	      	},
			assemblingData: [{
        		testItems: '万源',
        		testWay: '万源',
        		eligibilityCriteria: '万源',
        		dataRecord: '万源',
                isQualified: '万源',
        		photoEnclosure: '/static/img/logo.14cecf55.png',
				operatorTime:'万源',
				signature:'',
        	}],
			designUnitsData: [],//验收试验数组
			documentData: [{
				checkProject: '万源',
        		checkWay: '万源',
        		qualifiedCriteria: '万源',
        		photoEnclosure: '/static/img/logo.14cecf55.png',
				remarks:'万源',
        		isQualified: '万源',
				operatorTime:'万源',
				signature:'',
        	}],
	    }
  	},
  	methods: {
		  
		 // 查看装配/整机详情
	    assemblingHandle(type) {
			this.title = type ? "整机测试" : "装配环节"
	    	this.showDetailDialog = true;
			console.log(this.detailData)
			acceptanceApi.yuyanshouList({
		        deviceId:this.detailData[0].deviceId,
                deviceNo:this.detailData[0].deviceNo,
                modelState: type?"ZJCS" : "ZPHJ"
		    }).then(({ data }) => {
				this.assemblingData=data;
				
	        })
			
	    },
		//查看验收测试/例行试验
		designUnitsHandle(type) {
			this.title = type ? "验收试验" : "例行试验"
	    	this.showDesignDialog = true;
			acceptanceApi.yuyanshouList({
		         deviceId:this.detailData[0].deviceId,
                deviceNo:this.detailData[0].deviceNo,
                modelState: type?"YSSY" : "LXSY"
		    }).then(({ data }) => {
				this.assemblingData=data;
				this.designUnitsData=data;
	        })
	    },
		//查看文档验收
		documentHandle(row) {
	    	this.showDocumentDialog = true;
			acceptanceApi.documentList({
		         deviceId:this.detailData[0].deviceId,
                deviceNo:this.detailData[0].deviceNo,
                modelState:"DOC"
		    }).then(({ data }) => {
				this.documentData=data;
				
	        })
	    },
    	beforeClose() {
      		this.$emit("close")
    	},
		closeHandle() {
	    	this.showDetailDialog = false
			this.showDesignDialog = false
			this.showDocumentDialog = false
	    }
  	}
}
</script>
